import java.util.concurrent.CountDownLatch;

/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-08-01
 * Time: 20:26
 */
class people {
    private int num;
    public people(int num) {
        this.num=num;
    }
    public int getNum() {
        return num;
    }
}
public class demo3 {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch count = new CountDownLatch(10);

        for(int i=0;i<10;i++) {
            people p = new people(i);
            Thread t = new Thread() {
                public void run() {
                    try {
                        sleep((long) (Math.random()*10000));
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(p.getNum()+"号选手冲线");
                    count.countDown();
                }
            };
            t.start();
        }
        count.await();
    }
}
